<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>微信商城</title>
		<meta name="viewport" content="initial-scale=1, maximum-scale=1">
		<link rel="shortcut icon" href="/favicon.ico">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" href="css/mui.min.css" />
		<link rel="stylesheet" href="css/style.css" />
		<style type="text/css">
			.balance{
				color: #c40;
			}
			/*6.6*/
			.me-express div{
				position: relative;
			}
			.mui-badge1 {
			    line-height: .8rem!important;
			    line-height: 1rem;
			    padding: 0px 4px;
			    color: white;
			    border-radius: 100px;
			    background-color: #f6383a;
			    position: absolute;
			    z-index: 20;
			    top: 5px;
			    right: 22%;
			    padding: 0px 3.5px 0px 3.5px;
			}
		</style>
	</head>

	<body>
		<div class="me-content">
			<div class="me-head" style="height: 8rem;">
				<div class="me-head-message" style="width: 50%;float: left;">
					<div id="me-loading">
						<span id="ab" class="me-pic middle"></span>
						<p id="middle" class="middle"></p>
						<!--<img src="img/back-ri.png" alt="" height="50%" class="float-ri back-ri"/>-->
					</div>
				</div>
				<div class="me-head-my" style="width: 50%;float: right;height: 6rem;">
					<!--<div onclick="tz('my-coupon1.html','my-coupon1')"  class="me-head-my-ticket" id="coupon">
								<p>3张</p>
								<p>我的优惠劵</p>
							</div>-->
					<div onclick="tz('my-wallet.html','my-wallet')" class="me-head-my-money me-head-my-ticket" id="me-wallet" style="padding-top: 1.5rem;margin-left: 2rem;">
						<p class="balance">￥0.00</p>
						<p>账户余额</p>
					</div>
				</div>
			</div>
			<div class="me-content">
				<div class="me-order" id="me-order">
					<img src="img/order.png" alt="" height="60%" style="margin-left: 10px;" class="middle" />
					<span class="middle">我的订单</span>
					<img src="img/back-ri.png" alt="" class="float-ri" height="60%" style="margin-top: .3rem;margin-right: 10px;margin-left: 5px;" />
					<span onclick="tz1('myorder1.html','my-order','0')" class="float-ri" style="color: #c1c1bf;">全部订单</span>
				</div>
				<div class="me-express">
					<div onclick="tz1('myorder1.html#daidahuo','my-order','1')">
						<img src="img/order-1.png" alt="" height="30%" style="margin-top: .5rem;margin-bottom: .1rem;" /><br />
						<span>待付款</span>
						<span id="b0" class=" mui-badge1 "></span>
					</div>
					<div onclick="tz1('myorder1.html#daidahuo','my-order','2')">
						<img src="img/order-2.png" alt="" height="30%" style="margin-top: .5rem;margin-bottom: .1rem;" /><br />
						<span>待发货</span>
						<span id="b1" class=" mui-badge1 "></span>
					</div>
					<div onclick="tz1('myorder1.html#daidahuo','my-order','3')">
						<img src="img/order-3.png" alt="" height="30%" style="margin-top: .5rem;margin-bottom: .1rem;width: 1rem;" /><br />
						<span>待收货</span>
						<span id="b2" class=" mui-badge1 "></span>
					</div>
					<div onclick="tz1('myorder1.html#daidahuo','my-order','4')">
						<img src="img/order-4.png" alt="" height="30%" style="margin-top: .5rem;margin-bottom: .1rem;" /><br />
						<span>待评论</span>
						<span id="b3" class=" mui-badge1 "></span>
					</div>
					<div onclick="tz1('return.html','my-order')">
						<img src="img/order-5.png" alt="" height="30%" style="margin-top: .5rem;margin-bottom: .1rem;" /><br />
						<span>退换货</span>
						<span></span>
					</div>
				</div>

				<div class="me-function">
					<div onclick="tz('corporate-welfare.html','welfare')" id="me-marketing">
						<img src="img/market.png" height="30%" style="margin-top:0.8rem;margin-bottom: 0.2rem;" /><br />
						<span>企业商城</span>
					</div>
					<div onclick="tz('my-coupon.html','coupon')" id="me-fulidai">
						<img src="img/dai.png" height="30%" style="margin-top:0.8rem;margin-bottom: 0.2rem;" /><br />
						<span>企业福利袋</span>
					</div>
					<div onclick="tz('marketing.html','marketing')" id="me-active">
						<img src="img/fun1.png" height="30%" style="margin-top:0.8rem;margin-bottom: 0.2rem;" /><br />
						<span>营销活动</span>
					</div>
					<div onclick="tz('my-address.html','my-address')" id="address">
						<img src="img/fun2.png" height="30%" style="margin-top:0.8rem;margin-bottom: 0.2rem;" /><br />
						<span>收货地址</span>
					</div>
					<div onclick="tz2('my-help.html','my-help')" id="me-help">
						<img src="img/fun3.png" height="30%" style="margin-top:0.8rem;margin-bottom: 0.2rem;" /><br />
						<span>用户帮助</span>
					</div>
					<div class="conserer">
						<img src="img/fun4.png" height="30%" style="margin-top:0.8rem;margin-bottom: 0.2rem;" /><br />
						<span>联系客服</span>
					</div>
					<div onclick="tz('complaint.html','complaint')">
						<img src="img/fun5.jpg" height="30%" style="margin-top:0.8rem;margin-bottom: 0.2rem;" /><br />
						<span>投诉建议</span>
					</div>
					<div onclick="tz('my-setting.html','my-setting')" id="setting">
						<img src="img/fun6.png" height="30%" style="margin-top:0.8rem;margin-bottom: 0.2rem;" /><br />
						<span>设置</span>
					</div>
				</div>
			</div>
			<nav class="footer mui-bar-tab">
				<a class="tab-item external" href="tab-home.html">
					<img class="a1" src="img/home1.png" alt="" /><br />
					<span >首页</span>
				</a>
				<a class="tab-item external " href="tab-category.html">
					<img class="a2" src="img/category.png" alt="" /><br />
					<span>分类</span>
				</a>
				<span id="tanchu" class="tab-item external">
						<div><img src="img/tab.png" alt="" id="tab-add"/></div>
					</span>
				<a class="tab-item external" href="tab-cart.html">
					<img class="a3" src="img/cart.png" alt="" /><br />
					<span>购物车</span>
				</a>
				<a class="tab-item external a4" href="tab-me.html">
					<img class="a4" src="img/mine1.png" alt="" /><br />
					<span style="color: #e9af29;">我的</span>
				</a>
			</nav>
		</div>
		<script src="js/mui.min.js"></script>
		<script src="js/jquery-3.1.1.min.js" type="text/javascript"></script>
		<script src="js/url.js" type="text/javascript"></script>
		<script type="text/javascript">
			//截取头像		
			//		function replaceAll(str , replaceKey , replaceVal){
			//		  var reg = new RegExp(replaceKey , 'g');//g就是代表全部
			//		  return str.replace(reg , replaceVal || '');
			//		}
			//		temp = temp.replace(new RegExp("\\\\","gm"),"/");	
			//			mui.plusReady(function() {
			//				document.addEventListener('me', function() {
			////					var ab =true;
			//					getmoney();
			//					hqzl();
			////					console.log('刷新444')
			//				})
			//			})

			//			alert(localStorage.isAdmin );
			$(function() {
				
				if(localStorage.isAdmin == 2) {
					//     	  	alert("您是企业用户");
					$('#me-marketing').css('display', 'black');
					$('#me-fulidai').css('display', 'black');

				} else if(localStorage.isAdmin == 1) {
					//     	  	alert("您不是企业用户");
					$('#me-marketing').css('display', 'none');
					$('#me-fulidai').css('display', 'none');
				}
			});
			/*6.5*/
			orderList();
			function orderList() {
				$.ajax({
					url: ur + '/mobilemember/frontOrder/orderlist?time=' + new Date(),
					type: 'post',
					dataType: 'json',
					headers: {
						'X-Token': localStorage.token,
					},
					data: {
						'orderVO.status': 1,
						'numPerPage':10,
						'pageNum':'',
						'pageRequest':1
						//								'status':status
					},
					success: function(data) {
						//商品叠加
						if(data.result.meta.code == 201 && data.paginator.totalCount==0) {
                            var a = JSON.stringify(data.statusNum);
							var b = (a.replace('[', '').replace(']', '')).split(',');
							console.log(b.length);
							console.log(b[0]);
							if(b[0] != 0) {
								$('#b0').css('display','block');
								$('#b0').text(b[0]);
							}else if(b[0] == 0){
								$('#b0').css('display','none');
							}
							if(b[1] != 0) {
								$('#b1').css('display','block');
								$('#b1').text(b[1]);
							}else if(b[1] == 0){
								$('#b1').css('display','none');
							}
							if(b[2] != 0) {
								$('#b2').css('display','block');
								$('#b2').text(b[2]);
							}else if(b[2] == 0){
								$('#b2').css('display','none');
							}
							if(b[3] != 0) {
								$('#b3').css('display','block');
								$('#b3').text(b[3]);
							}else if(b[3] == 0){
								$('#b3').css('display','none');
							}
						}else if(data.result.meta.code == 201 && data.paginator.totalCount!=0){
						}else if(data.result.meta.code == 200) {
							var a = JSON.stringify(data.statusNum);
							var b = (a.replace('[', '').replace(']', '')).split(',');
							if(b[0] != 0) {
								$('#b0').css('display','block');
								$('#b0').text(b[0]);
							}else if(b[0] == 0){
								$('#b0').css('display','none');
							}
							if(b[1] != 0) {
								$('#b1').css('display','block');
								$('#b1').text(b[1]);
							}else if(b[1] == 0){
								$('#b1').css('display','none');
							}
							if(b[2] != 0) {
								$('#b2').css('display','block');
								$('#b2').text(b[2]);
							}else if(b[2] == 0){
								$('#b2').css('display','none');
							}
							if(b[3] != 0) {
								$('#b3').css('display','block');
								$('#b3').text(b[3]);
							}else if(b[3] == 0){
								$('#b3').css('display','none');
							}
						}
					},
					error: function(e) {
						console.log(JSON.stringify(e) + '<<<<错误');
					}
				})
			}
			
			/*拨打客服电话*/
			$('.conserer').on('tap', function() {
				var token = localStorage.token;
				if(!localStorage.token || localStorage.token == undefined || localStorage.token == '') {
					mui.toast('请先登录');
					mui.openWindow({
						url: 'login.html',
						id: 'login',
						show: 'pop-in'
					});
				} else {
					var btnArray = ['否', '是'];
					mui.confirm('确认拨打电话，确认？', '魏远商城', btnArray, function(e) {
						if(e.index == 1) {
							window.location.href = "tel:02082006150";
						}
					})
				}

			})

			$(function() {
				if(!localStorage.token || localStorage.token == undefined || localStorage.token == '') {
					//									alert(111);
					//              alert(localStorage.token) ; 
					//					var count = true;
					//					if(count) {
					mui.toast('您还没有登录');
					//						count = false;
					//					}
					$('#middle').text("登录/注册");
					$('#ab').css('background-image', "url('img/nogood1.png')");
				} else if(localStorage.token) {
					hqzl();

				}
			})
			document.addEventListener('refreshtabme', function(event) {
				hqzl();
			});

			//获取资料接口
			//						hqzl();
			function hqzl() {
				$.ajax({
					url: ur + '/mobilemember/frontmember/getInfo?time=' + new Date(),
					type: 'post',
					dataType: 'json',
					headers: {
						'X-Token': localStorage.token
					},
					data: '',
					success: function(data) {
						//						console.log(data);
						if(data.result.meta.code == 200) {
							var headp = data.result.data.headphoto;
							if(headp == '' || headp == undefined) {
								$('#ab').css('background-image', "url('img/nogood1.png')");
							} else {
								$('#ab').css('background-image', "url(" + picur + headp + ")");
							}
							var name = data.result.data.nickName;
							var phone = localStorage.phone;
							if(name == '' || name == null) {
								$('#middle').text(phone);
							} else {
								$('#middle').text(name);
							}
						} else if(data.result.meta.code == 303) {

							$('#middle').text("登录/注册");
							$('#ab').css('background-image', "url('img/nogood1.png')");
							//							alert(ab);
							//							if(ab){
							//								mui.toast('登录已过期，请重新登录');
							//								ab=false;
							//							}
							mui.toast('登录已过期，请重新登录');
							localStorage.token = '';
							//				        alert(localStorage.token);
						}
					},
					error: function(e) {
						//						console.log(JSON.stringify(e));
					}
				})
			}

			//登录判断localStorage.headphoto
			$('#me-loading').on('tap', function() {
				var token = localStorage.token;
				if(!localStorage.token || localStorage.token == undefined || localStorage.token == '') {
					mui.openWindow({
						url: 'login.html',
						id: 'login',
						show: 'pop-in'
					});
				} else {
					mui.openWindow({
						url: 'my-personal.html',
						id: 'personal',
						show: 'pop-in'
					});
				}
			})

			/*获取账户余额*/
			getmoney();

			function getmoney() {
				$.ajax({
						url: ur + '/mobilemember/shoppingcart/getMemberAcountBalance?time=' + new Date(),
						type: 'GET',
						dataType: 'json',
						headers: {
							"X-Token": localStorage.token
						},
						data: {}
					})
					.done(function(data) {
						if(!data.value){
							$('.balance').text('￥0.00').css('color','#c40');
						}else{
							var money = data.value;
							$('.balance').text('￥'+parseFloat(money).toFixed(2));
							if($('.balance').text() == '￥0.00'){
								$('.balance').css('color','#c40');
							}else{
								$('.balance').css('color','black');
							}
						}
						
					})
			}
//			alert()
//			if($('.balance').text()=='0.00'){
//				$('.balance').text('￥0.00').css('color','#c40');
//			}
			//			页面跳转
			function tz(a, b) {
				var token = localStorage.token;
				if(!localStorage.token || localStorage.token == undefined || localStorage.token == '') {

					mui.toast('请先登录');
					mui.openWindow({
						url: 'login.html',
						id: 'login',
						show: 'pop-in'
					});
				} else {
					localStorage.numtowhere = 59;
					mui.openWindow({
						url: a,
						id: b,
						show: 'pop-in',

					})
				}
			}

			//			页面跳转
			function tz1(a, b, c) {
				var token = localStorage.token;
				if(!localStorage.token || localStorage.token == undefined || localStorage.token == '') {

					mui.toast('请先登录');
					mui.openWindow({
						url: 'login.html',
						id: 'login',
						show: 'pop-in'
					});
				} else {
					localStorage.status_tab = c
					//					console.log(localStorage.status_tab);
					mui.openWindow({
						url: a,
						id: b,
						show: 'pop-in',
						//						extras:{
						//							targetId:c
						//						}
					})

					//					var tabme = plus.webview.getWebviewById('my-order.html');
					//	                    mui.fire(tabme,'golist');
				}
			}
			//跳转
			function tz2(a, b, c) {
				mui.openWindow({
					url: a,
					id: b,
					show: 'pop-in',
				})
			}
		</script>
	</body>

</html>